package com.mark.web.data.util;

/**
 * @Description: 验证码工具类
 * @Author: Mark
 * @CreateDate: 2018/7/27.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpSession;

public class VerificationCodeUtil {
    public static boolean checkVerifyCode(String codeValue, HttpSession session){
        //验证码期望值
        String verifyCodeExpected = (String) session.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
        //验证码的实际输入值
        String verifyCodeActual = codeValue;
        if(StringUtils.isBlank(verifyCodeActual) || !StringUtils.endsWithIgnoreCase(verifyCodeExpected,verifyCodeActual)){
            return  false;
        }
        return true;
    }
}
